package com.training.servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.training.dao.EmployeeDAO;
import com.training.dto.Employee;
import com.training.exceptions.TMSSystemException;

/**
 * Servlet implementation class UpdateEmployeeServlet
 */
public class UpdateEmployeeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateEmployeeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		
		 Employee employee = new Employee();
		 
		 employee.setFirstName(request.getParameter("firstName"));
		 employee.setLastName(request.getParameter("lastName"));
		 employee.setPassword(request.getParameter("password"));
		 employee.setUserName(request.getParameter("userName"));
		 
		 EmployeeDAO employeeDAO = new EmployeeDAO();
		 try {
			if(employeeDAO.updateEmployee(employee))
			 {
				 request.getSession().setAttribute("updateStatus", "Successfully Updated");
			 }
			else
			{
				 request.getSession().setAttribute("updateStatus", "Update Failure");

			}
		} catch (TMSSystemException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  


	
	
	}

}
